package edu.hwadee.action;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import edu.huadee.entity.Carsafety;
import edu.hwadee.service.CarSafetyService;

public class CarSafetyAction extends ActionSupport implements ModelDriven<Carsafety> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private CarSafetyService carsafetyservice;
	private Carsafety carsafety = new Carsafety();

	public CarSafetyService getCarsafetyservice() {
		return carsafetyservice;
	}

	public void setCarsafetyservice(CarSafetyService carsafetyservice) {
		this.carsafetyservice = carsafetyservice;
	}

	public Carsafety getCarsafety() {
		return carsafety;
	}

	public void setCarsafety(Carsafety carsafety) {
		this.carsafety = carsafety;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public Carsafety getModel() {
		// TODO Auto-generated method stub
		return carsafety;
	}
	
	public String addCarSafety() {

		if(carsafetyservice.exits(carsafety.getCarSafetyId())) {
			carsafetyservice.save(carsafety);
			return "success";
		}
		return "error";
	}
}
